// SUGARSCAPE MODEL FOR SWARM
// Based on Nelson Minar's 1996-1997 model; modified by 
// Andre Manoel (andremanoel@gmail.com) with research  
// purposes. See file README for more information.

#import <space.h>				  // we use Space features
#import <gui.h>
#import "SugarSpace.h"
#import "ModelSwarm.h"

// The definition of a SugarAgent object. We inherit code from the generic
//   SwarmObject, which provides memory allocation and other niceties. It
//   does not provide any sort of agent behaviour, though, that's up to us
// First, there are a lot of state variables

@interface SugarAgent: SwarmObject
{
  SugarValue initialSugar;			  // how much sugar I've started
  SugarValue currentSugar;			  // how much sugar I hold
  SugarValue sugarMetabolism, normalSugMet;	  // how much sugar I need
  SpiceValue initialSpice;                        // how much spice I've started
  SpiceValue currentSpice;                        // how much spice I hold
  SpiceValue spiceMetabolism, normalSpiMet;       // how much spice I need
  SugarValue maxSugar;
  SpiceValue maxSpice;
  int vision;					  // how far I can see
  int foresight;				  // how many turns ahead I think
  int age;					  // how old I am
  int deathAge;					  // how old I can get

  int sex;					  // my sex; 0 for F, 1 for M  
  int pubertyAge, infertilityAge;		  // between these I'm fertile
  int fertile;					  // am I fertile?
  int inheritanceOn;
  id childList;
  
  int transmitCulture;				  // flag
  int tagString[11];				  // my cultural preferences
  
  int permitCombat;				  // flag
  int combatPrize;				  // prize for winning combat

  int allowTrading;				  // flag
  double turnSumPrices, turnProdPrices;	          // counters
  float turnVolume;
  int turnTrades;

  int diseaseOn;				  // flag
  int immuneSystem[50];				  // my immune system
  int diseaseList[100][15], numDiseases;	  // list of diseases
  int numActDiseases, actDiseases [100];	  // diseases acting

  int marked;  					  // flag

  int initX, initY;
  
  id modelSwarm;				  // my swarm
  SugarSpace *sugarSpace;			  // the sugarspace I live in

  @public
  int x, y;					  // my position
}

// The main behaviour of an object - do one 'time step', one action
- step;

// The agent movement rule M combined with combat rule K
- moveToBestOpenSpot;

// The sex and culture propagation rules, from book's chapter 3
- interactNeighbours;

// The disease dynamics
- diseaseCycle;

// Getter and setter methods
- setModelSwarm: s;
- setInitialSugar: (SugarValue)s;
- setSugarMetabolism: (SugarValue)m;
- setInitialSpice: (SpiceValue)s;
- setSpiceMetabolism: (SpiceValue)m;
- gainSugar: (SugarValue)su andSpice: (SpiceValue)sp;
- setVision: (int)v;
- setForesight: (int)f;
- setDeathAge: (int)s;
- setMaxSugar: (float)m1 MaxSpice: (float)m2;
- setSex: (int)s;
- setPubertyAge: (int)a;
- setInfertilityAge: (int)a;
- createChildList;
- setTransmitCulture: (int)f;
- setTagStringAt: (int)i withValue: (int)t;
- setPermitCombat: (int)f withPrize: (int)p;
- setAllowTrading: (int)f;
- setDiseaseOn: (int)d withAsMuchAs: (int)n;
- setImmuneStringAt: (int)i withValue: (int)s;
- setDiseaseListLin: (int)i Col: (int)j withValue: (int)d;
- activDisease: (int)d;
- resetDistance;

- (int)getVision;
- (int)getForesight;
- (int)getAge;
- (int)getSex;
- (int)getTagNumberOfZeros;
- (int)getTribe;
- (SugarValue)getCurrentSugar;
- (SugarValue)getSugarMetabolism;
- (SpiceValue)getCurrentSpice;
- (SpiceValue)getSpiceMetabolism;
- (float)getWelfare;
- (float)getMrs;
- (float)getWelfareWithSugar: (SugarValue)su withSpice: (SpiceValue)sp
                   withPollut: (float)pol;
- (float)getMrsWithSugar: (SugarValue)su withSpice: (SpiceValue)sp;
- (double)getSumPrices;
- (double)getProdPrices;
- (float)getVolume;
- (int)getNoTrades;
- (int)getSickness;
- (float)getDistance;

// Display code so you can see the agents moving
- drawSelfOn: (id <Raster>)r;

@end
